<?php

/**
 * Enquete form.
 *
 * @package    form
 * @subpackage Midia
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
 */
class EnqueteOpcaoFormValidatorSchema extends sfValidatorSchema
{
	protected function configure($options = array(), $messages = array())
	{
		$this->addMessage('ds_opcao', 'A Opção é obrigatória.');
	}

	protected function doClean($values)
	{
		$errorSchema = new sfValidatorErrorSchema($this);

		foreach($values as $key => $value)
		{
			$errorSchemaLocal = new sfValidatorErrorSchema($this);

			if (!$value['ds_opcao'])
				unset($values[$key]);

			if (count($errorSchemaLocal))
				$errorSchema->addError($errorSchemaLocal, (string) $key);
		}

		if (count($errorSchema))
			throw new sfValidatorErrorSchema($this, $errorSchema);

		return $values;
	}
}